package work3

class practice3 {
  """def addOne(intList:List[Int]): Unit ={
    for(i <-intList){
      var newintList=i+1
      return newintList
    }
  }
  def filterEven(intList:List[Int]): Unit ={
    for(x<-intList){
      if(x%2==0){
        var newintList1=x
        return newintList1
      }
    }
  }
  def mapReduce(intList:List[Int]): Unit ={
  }"""
  object Functions {
    def addOne(list: List[Int]): List[Int] = list.map(_ + 1)

    def filterEven(list: List[Int]): List[Int] = list.filter(_ % 2 == 0)

    def mapReduce(list: List[Int])(mapFunc: Int => Int)(reduceFunc: (Int, Int) => Int): Int = {
      list.map(mapFunc).reduce(reduceFunc)
    }
  }

}
